package cn.net.wanji.entity.deviceInfo;

import cn.net.wanji.entity.MyDeviceInfo;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author guodejun
 * @createTime 2022/11/18 16:26
 * @description
 */
@Data
public class DeviceInfo {

    String gantryId;
    String createTime;

    List<ControllerInfo> controllerInfoList;
    List<CameraInfo> cameraInfoList;
    List<LaserInfo> laserInfoList;
    List<RsuInfo> rsuInfoList;

    public List<MyDeviceInfo> getMyDeviceInfoList() {

        // 获取站点 id
        String siteCode = gantryId;

        List<MyDeviceInfo> myDeviceInfos = new ArrayList<>();

        // 控制器
        if (controllerInfoList != null) {
            List<MyDeviceInfo> controllerMyDeviceInfo = controllerInfoList.stream().map(item -> item.getDevBaseInfo(siteCode, "0101")).
                    collect(Collectors.toList());
            myDeviceInfos.addAll(controllerMyDeviceInfo);
        }

        // 相机
        if (cameraInfoList != null) {
            List<MyDeviceInfo> cameraMyDeviceInfo = cameraInfoList.stream().map(item -> item.getDevBaseInfo(siteCode, "0102")).collect(Collectors.toList());
            myDeviceInfos.addAll(cameraMyDeviceInfo);
        }
        // 激光雷达
        if (laserInfoList != null) {
            List<MyDeviceInfo> laserMyDeviceInfo = laserInfoList.stream().map(item -> item.getDevBaseInfo(siteCode, "0103")).collect(Collectors.toList());
            myDeviceInfos.addAll(laserMyDeviceInfo);
        }
        // 路侧单元
        if (rsuInfoList != null) {
            List<MyDeviceInfo> rsuMyDeviceInfo = rsuInfoList.stream().map(item -> item.getDevBaseInfo(siteCode, "0104")).collect(Collectors.toList());
            myDeviceInfos.addAll(rsuMyDeviceInfo);
        }
        return myDeviceInfos;
    }
}
